import itertools

with open('input.txt') as file:
    numbers = [int(line) for line in file.readlines()]

    for (i, number) in enumerate(numbers[25:], 25):
        # 'i' is first not pre index
        # take two numbers from numbers[i-25:i]
        for pair in itertools.combinations(numbers[i-25:i], 2):
            if sum(pair) == number:
                break
        # no any two nums' sum == number
        else:
            break

    # number is invalid value

    for n in itertools.count(2):
        for i in range(len(numbers) - n):
            group = numbers[i : i + n]
            if sum(group) == number:
                print(min(group) + max(group))
                break
        else:
            continue
        break